import json

from ronglian_sms_sdk import SmsSDK

# 封装容联云
accId = '8aaf07087a331dc7017ae5ce36e83649'
accToken = '5ea139cb96174d499534494e9489904c'
appId = '8aaf07087a331dc7017ae5ce37be3650'


def send_message(mobile, code, time):
    sdk = SmsSDK(accId, accToken, appId)
    tid = '1'
    datas = (code, time)
    resp = sdk.sendMessage(tid, mobile, datas)
    result = json.loads(resp)
    if result['statusCode'] == '000000':
        return True
    return False


# Redis
from django_redis import get_redis_connection


def get_redis():
    conn = get_redis_connection()
    return conn